package cn.jy.map.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import cn.jy.map.domain.AddressMsg;
import cn.jy.map.domain.AllGjzCollSituation;
import cn.jy.map.domain.Communrecord;
import cn.jy.map.domain.FiveLink;
import cn.jy.map.domain.GjzLc;
import cn.jy.map.domain.KeyProvider;
import cn.jy.map.domain.LcBaseLcblfy;
import cn.jy.map.domain.Nurse;
import cn.jy.map.domain.PlasmaResult;
import cn.jy.map.domain.ProviderNurse;
import cn.jy.map.domain.ProviderType;
import cn.jy.map.domain.PulpWeight;
import cn.jy.map.domain.RecruitmentMethod;
import cn.jy.map.domain.RegisterGtt;
import cn.jy.map.domain.RelHistory;
import cn.jy.map.domain.ThisLastDiff;
import cn.jy.map.domain.VillageColligate;
import cn.jy.map.domain.Wxjyy;
import cn.jy.map.domain.importantProvider;
import cn.jy.map.domain.UnSuccessInformation.BodyCheckJY;
import cn.jy.map.domain.UnSuccessInformation.BodyCheckMX;
import cn.jy.map.domain.UnSuccessInformation.JYTypeNum;
import cn.jy.map.domain.UnSuccessInformation.UpdateLC;
import cn.jy.map.domain.achieve.JZAchievements;
import cn.jy.map.domain.achieve.LjJX;
import cn.jy.map.domain.achieve.XYFZJX;
import cn.jy.map.domain.achieve.YGJX;
import cn.jy.map.domain.achieve.YLDX;
import cn.jy.map.service.GjzDzJwdService;
import cn.jy.map.service.JZAchievementsService;
import cn.jy.map.service.JzjyloasService;
import cn.jy.map.service.LcBlfyService;
import cn.jy.map.service.LoadAllDataService;
import cn.jy.map.service.MapNewService;
import cn.jy.map.service.PlasmaStatisticsService;
import cn.jy.map.service.RecruitmentMethodService;
import cn.jy.map.service.VillageColligateService;
import cn.jy.map.utils.FrequencyResult;
import cn.jy.map.utils.MapUtils;
import cn.jy.map.utils.Results;

/**
 * 地图控制器
 * 
 * @author Administrator
 *
 */
@Controller("/")
public class MapController {

	@Autowired
	private GjzDzJwdService gjzDzJwdService;
	@Autowired
	private LoadAllDataService loadDataService;
	@Autowired
	private VillageColligateService villageColligateService;
	@Autowired
	private LcBlfyService lcBlfyService;
	@Autowired
	private MapNewService mapNewService;
	@Autowired
	private JzjyloasService jzjyloasService;

	@Autowired
	private PlasmaStatisticsService plasmaStatisticsService;

	@Autowired
	private JZAchievementsService jZAchievementsService;
	@Autowired
	private RecruitmentMethodService recruitmentMethodService;

	@RequestMapping("map/load")
	public void load(HttpServletRequest request, HttpServletResponse response) {

		try {
			request.getRequestDispatcher(
					"http://api.map.baidu.com/geocoder?key=aa809lGnQry8viRmYfiaod0rMjctYeuR&output=json&address=甘肃省陇南市宕昌县城关镇辖区")
					.forward(request, response);
		} catch (ServletException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	/**
	 * 加载供浆者经纬度基本数据
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("map/loadGjzJwdData")
	public void loadGjzJwdData(HttpServletRequest request, HttpServletResponse response) {

		String date = request.getParameter("date");
		loadDataService.loadGjzDzJwdData(date);

	}

	/**
	 * 加载供浆者经纬度基本数据
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("map/loadAllNurseProviderLc")
	public void loadAllNurseProviderLc(HttpServletRequest request, HttpServletResponse response) {

		loadDataService.loadAllNurseProviderLc();

	}

	/**
	 * 装载指定村落的综合统计信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/loadVillageColligateMsg")
	public void loadVillageColligateMsg(HttpServletRequest request, HttpServletResponse response) throws Exception {

		String villageName = request.getParameter("villageName");
		if (villageName != null) {
			villageName = new String(villageName.getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																					// "UTF-8");
		}

		villageColligateService.loadVillageColligateMsg(villageName);

	}

	/**
	 * 加载供浆者轮次信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("map/loadGjzLc")
	public void loadGjzLc(HttpServletRequest request, HttpServletResponse response) {

		loadDataService.loadGjzLcData();
		// loadDataService.loadRegGjzLcData(date);
	}

	/**
	 * 重新加载轮次表中的轮次信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("map/loadGjzRound")
	public void loadGjzRound(HttpServletRequest request, HttpServletResponse response) {
		String providerNo = request.getParameter("providerNo");
		loadDataService.loadGjzRoundData(providerNo);
		// loadDataService.loadRegGjzLcData(date);
	}

	/**
	 * 加载供浆者甘特图信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("map/loadGjzRegGtt")
	public void loadGjzRegGtt(HttpServletRequest request, HttpServletResponse response) {
		String date = request.getParameter("date");
		loadDataService.loadGjzRegGtt(date);

	}

	/**
	 * 获取地址经纬度
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/gjzDzJwd")
	public @ResponseBody List<AddressMsg> getGjzDzJwd(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String code = request.getParameter("code");
		String date = request.getParameter("date");
		String isRegist = request.getParameter("isRegist");// 是否是登记（0/1）

		String lookBeginGjz = request.getParameter("lookBeginGjz");// 是否查看某一天的很早就来登记的浆员

		List<AddressMsg> dzJwdList = gjzDzJwdService.getDzJwdList(code, date, isRegist, lookBeginGjz);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(dzJwdList);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return dzJwdList;

	}

	/**
	 * 获取轮次表
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getGjzLc")
	public @ResponseBody List<GjzLc> getGjzLc(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");
		String address = request.getParameter("address");
		if (address != null) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																			// "UTF-8");
		}

		List<GjzLc> gjzLc = gjzDzJwdService.getGjzLc(address, date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(gjzLc);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return gjzLc;

	}

	/**
	 * 获取轮次表，根据浆员类型和村落，默认为获取全部类型全部村落的轮次
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getGjzLcByType")
	public @ResponseBody List<GjzLc> getGjzLcByType(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String type = request.getParameter("type");
		String address = request.getParameter("address");//
		if (address != null && !"".equals(address)) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");
		}

		List<GjzLc> gjzLc = gjzDzJwdService.getGjzLc_ta(type, address);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(gjzLc);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return gjzLc;

	}

	/**
	 * 获取登记信息甘特图
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getRegGtt")
	public @ResponseBody List<RegisterGtt> getRegGtt(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String address = new String(request.getParameter("address").getBytes("ISO-8859-1"), "UTF-8");// URLDecoder.decode(request.getParameter("address"),
																										// "UTF-8");
		String date = request.getParameter("date");
		String isNew = request.getParameter("isNew");

		List<RegisterGtt> retisterGtt = gjzDzJwdService.getRetisterGtt(address, date, isNew);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(retisterGtt);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return retisterGtt;

	}

	/**
	 * 获取积极浆员的轮次表
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getJijGjzLc")
	public @ResponseBody List<GjzLc> getJijGjzLc(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");
		String address = new String(request.getParameter("address").getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																										// "UTF-8");

		List<GjzLc> gjzLc = gjzDzJwdService.getJijGjzLc(address, date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(gjzLc);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return gjzLc;

	}

	/**
	 * 获取积极浆员登记信息甘特图
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getJijRegGtt")
	public @ResponseBody List<RegisterGtt> getJijRegGtt(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String address = new String(request.getParameter("address").getBytes("ISO-8859-1"), "UTF-8");// URLDecoder.decode(request.getParameter("address"),
																										// "UTF-8");
		String date = request.getParameter("date");

		List<RegisterGtt> retisterGtt = gjzDzJwdService.getJijRetisterGtt(address, date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(retisterGtt);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return retisterGtt;

	}

	/**
	 * 获取当前轮次
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getThisRound")
	public @ResponseBody Map<String, String> getThisRound(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		String thisRound = gjzDzJwdService.getThisRound();

		String callback = request.getParameter("callback");
		Map<String, String> map = new HashMap<String, String>();
		map.put("thisRound", thisRound);
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;

	}

	/**
	 * 获取某个日期前，所有浆员的献浆情况
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getAllGjzCollnSituation")
	public @ResponseBody AllGjzCollSituation getAllGjzCollnSituation(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");

		AllGjzCollSituation situation = gjzDzJwdService.getAllGjzCollSituation(date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(situation);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return situation;

	}

	/**
	 * 获取某个地域下，所有类型的浆员
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getAllGjzDzJwd")
	public @ResponseBody Map<String, List<AddressMsg>> getAllGjzDzJwd(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");
		if (date == null || "".equals(date)) {
			date = MapUtils.getNowOnlyDateFomat1();
		}
		Map<String, List<AddressMsg>> map = gjzDzJwdService.getAllGjzDzJwdBySituation(date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;

	}

	/**
	 * 获取某个地域下，分类的不同类型的浆员
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getAllGjzDzJwdBySituation")
	public @ResponseBody List<AddressMsg> getAllGjzDzJwdBySituation(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");
		String gjzType = request.getParameter("gjzType");
		if (gjzType == null || "".equals(gjzType)) {
			gjzType = "-1";
		}
		if (date == null || "".equals(date)) {
			date = MapUtils.getNowOnlyDateFomat1();
		}
		List<AddressMsg> list = gjzDzJwdService.getAllGjzDzJwdBySituation(Integer.parseInt(gjzType), date);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return list;

	}

	/**
	 * 获取链接/未链接的浆员的地址定位信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getConnGjz")
	public @ResponseBody List<AddressMsg> getConnGjz(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String isConn = request.getParameter("isConn");

		if ("1".equals(isConn)) {
			// 链接
			isConn = "6";
		} else {
			// 未链接
			isConn = "7";
		}

		List<AddressMsg> list = gjzDzJwdService.getAllGjzDzJwdBySituation(Integer.parseInt(isConn),
				MapUtils.getNowOnlyDateFomat1());

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return list;

	}

	/**
	 * 根据地域，获取这个地域下面的不同类型的浆员的轮次表 供浆者类型：
	 * 1：忠诚浆员，2：服务浆员，3：今年新浆员，4：休眠浆员，5：流失浆员，6：今年进站的被链接了的浆员，7：休眠中未链接浆员，8：今年进站的浆员，9：今年未进站的浆员，10：休眠中已链接的浆员
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getGjzLcBySituation")
	public @ResponseBody List<GjzLc> getAllGjzLcBySituation(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String date = request.getParameter("date");
		String gjzType = request.getParameter("gjzType");
		String address = new String(request.getParameter("address").getBytes("ISO-8859-1"), "UTF-8");
		if (gjzType == null || "".equals(gjzType)) {
			gjzType = "-1";
		}
		if (date == null || "".equals(date)) {
			date = MapUtils.getNowOnlyDateFomat1();
		}
		List<GjzLc> list = gjzDzJwdService.getGjzLcBySituation(Integer.parseInt(gjzType), date, address);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return list;

	}

	/**
	 * 设置重点村落
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/setKeyVillage")
	public void setKeyVillage(HttpServletRequest request, HttpServletResponse response,
			@RequestBody List<VillageColligate> villages) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		// if(villages != null && villages.size()>0){
		// for (VillageColligate vill : villages) {
		// String villageName = vill.getVillageName();
		// villageName = new String(villageName.getBytes("ISO-8859-1"),"UTF-8");
		// vill.setVillageName(villageName);
		// }
		// }
		villageColligateService.setKeyVillage(villages);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString("ok");

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 获取重点村落
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getKeyVillageDzJwd")
	public @ResponseBody Map<String, List<AddressMsg>> getKeyVillageDzJwd(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		Map<String, List<AddressMsg>> map = gjzDzJwdService.getKeyVillageDzJwd();

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;

	}

	/**
	 * 获取所有村落
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getVillageColligate")
	public @ResponseBody Map<String, List<VillageColligate>> getVillageColligate(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String villageName = request.getParameter("villageName");

		if (villageName != null && !"".equals(villageName)) {
			villageName = new String(villageName.getBytes("ISO-8859-1"), "UTF-8");
		}
		List<VillageColligate> list = villageColligateService.getVillageColligateMsg(villageName);
		List<VillageColligate> totalList = villageColligateService.getTotalVillageColligate();

		Map<String, List<VillageColligate>> map = new HashMap<String, List<VillageColligate>>();
		map.put("allVills", list);
		map.put("totalVills", totalList);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;

	}

	/**
	 * 获取今天进站的人的所有村落
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getTodayVill")
	public @ResponseBody List<VillageColligate> getTodayVill(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String date = request.getParameter("date");

		List<VillageColligate> list = villageColligateService.getVillageColligateByDate(date);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return list;

	}

	/**
	 * 查询某个浆员某个日期的临床不良反应记录
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getLcBlfy")
	public @ResponseBody LcBaseLcblfy getLcBlfy(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String date = request.getParameter("date");
		String providerNo = request.getParameter("providerNo");

		LcBaseLcblfy blfy = lcBlfyService.getLcBlfy(providerNo, date);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(blfy);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return blfy;

	}

	/**
	 * 提交重点浆员类型
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/setKeyProvider")
	public void setKeyProvider(HttpServletRequest request, HttpServletResponse response,
			@RequestBody List<KeyProvider> keyProvider) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString("ok");

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 查询和某个浆员同一天来献浆的所有浆员列表
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getSameTimeComed")
	public @ResponseBody List<String> getSameTimeComed(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String date = request.getParameter("date");
		String providerNo = request.getParameter("providerNo");
		String address = request.getParameter("address");
		String nurseId = request.getParameter("nurseId");

		if (address != null && !"".equals(address)) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");
		}

		List<String> list = lcBlfyService.getSameTimeComed(providerNo, date, address, nurseId);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;

	}

	/**
	 * 查询所有护士列表
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@ResponseBody
	@RequestMapping("map/getNurse")
	public List<Nurse> getNurse(HttpServletRequest request, HttpServletResponse response) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		List<Nurse> list = lcBlfyService.getNurse();
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;

	}

	/**
	 * 查询指定浆员的所有的未献浆沟通记录
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getGtjl")
	public @ResponseBody Map<String, Object> getGtjl(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String providerNo = request.getParameter("providerNo");
		List<Communrecord> comm = mapNewService.getCommunrecord(providerNo);
		List<Communrecord> rem = mapNewService.getRemind(providerNo);
		List<Wxjyy> list = lcBlfyService.getGtjl(providerNo);

		Map<String, Object> data = new HashMap<String, Object>();
		data.put("comm", comm);
		data.put("rem", rem);
		data.put("wxjjl", list);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(data);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return data;

	}

	/**
	 * 更新浆员的管理信息，包括管理护士、管理义工、分组、重点浆员等
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/updateProviderManageMsg")
	public void updateProviderNurse(HttpServletRequest request, HttpServletResponse response,
			@RequestBody List<ProviderNurse> providerNurse) throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		lcBlfyService.updateProviderManageMsg(providerNurse);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString("ok");

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

	}

	/**
	 * 根据护士，获取这个护士链接的浆员的综合信息，包括：浆员的轮次信息、护士链接的所有人的综合统计信息，类似于根据村落统计村落的综合信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getNurseGjzLc")
	public @ResponseBody Map<String, Object> getNurseGjzLc(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String nurseId = request.getParameter("nurseId");// 护士ID
		String gjzType = request.getParameter("gjzType");// 浆员类型：所有、忠诚、复苏........
		String address = request.getParameter("address");// 地址

		if (address != null) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																			// "UTF-8");
		}

		int gt = -1;

		if (gjzType != null && !"".equals(gjzType)) {
			gt = Integer.parseInt(gjzType);
		}
		Map<String, Object> nurseGjzLc = lcBlfyService.getNurseGjzLc(nurseId, gt, address);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(nurseGjzLc);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return nurseGjzLc;

	}

	@RequestMapping("map/getjylxNum")
	public @ResponseBody Map<String, Object> getjylxNum(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String nurseId = request.getParameter("nurseId");
		String gjzType = request.getParameter("gjzType");// 浆员类型：所有、忠诚、复苏........
		String address = request.getParameter("address");// 地址

		if (address != null) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																			// "UTF-8");
		}

		int gt = -1;

		if (gjzType != null && !"".equals(gjzType)) {
			gt = Integer.parseInt(gjzType);
		}
		Map<String, Object> nurseGjzLc = lcBlfyService.getNurseGjzLc(nurseId, gt, address);
		Map<String, Object> map = new HashMap<String, Object>();
		List<GjzLc> obj = (List<GjzLc>) nurseGjzLc.get("jylc");
		List<JYTypeNum> list = new ArrayList<JYTypeNum>();
		Integer RTypeNum = 0;
		Integer NotPulpNum = 0;
		for (GjzLc gjzLc : obj) {
			if (gjzLc.getProviderNo().substring(0, 1).equals("R")) {
				RTypeNum++;
			} else if (gjzLc.getTimes() == 0 && !gjzLc.getProviderNo().substring(0, 1).equals("R")) {
				NotPulpNum++;
			}
		}
		List<String> a = lcBlfyService.getByNurseIdFiveLink(nurseId);
		HashSet<String> b = new HashSet<String>();
		for (String string : a) {
			b.add(string);
		}
		JYTypeNum jyTypeNum = new JYTypeNum();
		jyTypeNum.setRTypeNum(RTypeNum);
		jyTypeNum.setNotPulpNum(NotPulpNum);
		jyTypeNum.setFiveLinkNum(b.size());

		list.add(jyTypeNum);
		map.put("ngc", nurseGjzLc.get("ngc"));
		map.put("wxj", list);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;

	}

	/**
	 * 查看某个浆员的管理护士修改记录
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getNurseChangeHis")
	public @ResponseBody List<RelHistory> getNurseChangeHis(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String providerNo = request.getParameter("providerNo");

		List<RelHistory> list = lcBlfyService.getNurseChangeHis(providerNo);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;

	}

	/**
	 * 查看某个护士管理的所有村落集合
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getNurseVill")
	public @ResponseBody List<String> getNurseVill(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");

		String nurseId = request.getParameter("nurseId");

		List<String> list = lcBlfyService.getNurseVill(nurseId);

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;

	}

	/**
	 * 根据前台传过来的护士id和浆员类型确定浆员属于哪个村有多少人
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getByVills")
	public @ResponseBody List<String> getByVill(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String nurseId = request.getParameter("nurseId");
		String gjzType = request.getParameter("gjzType");// 浆员类型：所有、忠诚、复苏........
		String address = request.getParameter("address");// 地址

		int gt = -1;
		if (gjzType != null && !"".equals(gjzType)) {
			gt = Integer.parseInt(gjzType);
		}
		Map<String, Object> nurseGjzLc = lcBlfyService.getNurseGjzLc(nurseId, gt, address);
		List<GjzLc> obj = (List<GjzLc>) nurseGjzLc.get("jylc");
		StringBuilder sb = new StringBuilder();
		List<String> list = null;
		for (GjzLc gjzLc : obj) {
			sb.append("'" + gjzLc.getProviderNo() + "'" + ",");

		}
		if (sb.length() > 0 && sb != null) {
			list = lcBlfyService.getByVills(sb.toString().substring(0, sb.length() - 1));
		}

		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;

	}

	/**
	 * 查询五步链接信息
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getFiveLink")
	public @ResponseBody List<FiveLink> getFiveLink(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String cardId = request.getParameter("cardId");
		String date = request.getParameter("date");
		List<FiveLink> fiveLinks = lcBlfyService.getFiveLink(cardId, date);
		System.out.println(fiveLinks);
		List<FiveLink> result = new ArrayList<FiveLink>();
		for (int i = 0; i < fiveLinks.size(); i++) {
			FiveLink linkbean = new FiveLink();
			// 开始判断链接环节
			if (fiveLinks.get(i).getLJHJ() != null && fiveLinks.get(i).getLJHJ().length() < 3) {

				linkbean.setLJHJ(lcBlfyService.getLinkHj(fiveLinks.get(i).getLJHJ()));
			}

			if (fiveLinks.get(i).getLJHJ() != null) {
				if (fiveLinks.get(i).getLJHJ().length() > 3) {
					String spiltNum = fiveLinks.get(i).getLJHJ();
					String[] spiltArray = spiltNum.split(";");
					String hc1 = null;
					String hc2 = null;
					String hc3 = null;
					String hc4 = null;
					if (spiltArray.length == 2) {
						hc1 = lcBlfyService.getLinkHj(spiltArray[0]);
						hc2 = lcBlfyService.getLinkHj(spiltArray[1]);
						linkbean.setLJHJ(hc1 + ";" + hc2);
					}

					if (spiltArray.length == 3) {
						hc1 = lcBlfyService.getLinkHj(spiltArray[0]);
						hc2 = lcBlfyService.getLinkHj(spiltArray[1]);
						hc3 = lcBlfyService.getLinkHj(spiltArray[2]);
						linkbean.setLJHJ(hc1 + ";" + hc2 + ";" + hc3);
					}
					if (spiltArray.length == 4) {
						hc1 = lcBlfyService.getLinkHj(spiltArray[0]);
						hc2 = lcBlfyService.getLinkHj(spiltArray[1]);
						hc3 = lcBlfyService.getLinkHj(spiltArray[2]);
						hc4 = lcBlfyService.getLinkHj(spiltArray[3]);
						linkbean.setLJHJ(hc1 + ";" + hc2 + ";" + hc3 + ";" + hc4);
					}
				}
			}
			// 链接环节判断结束

			// 开始判断链接效果
			if (fiveLinks.get(i).getLJXG() != null && fiveLinks.get(i).getLJXG().length() < 3) {

				linkbean.setLJXG(lcBlfyService.getLinkXG(fiveLinks.get(i).getLJXG()));
			}
			if (fiveLinks.get(i).getLJXG() != null) {
				if (fiveLinks.get(i).getLJXG().length() > 3) {
					String spiltNum = fiveLinks.get(i).getLJXG();
					String[] spiltArray = spiltNum.split(";");
					String hc1 = null;
					String hc2 = null;
					String hc3 = null;
					String hc4 = null;
					if (spiltArray.length == 2) {
						hc1 = lcBlfyService.getLinkXG(spiltArray[0]);
						hc2 = lcBlfyService.getLinkXG(spiltArray[1]);
						linkbean.setLJXG(hc1 + ";" + hc2);
					}

					if (spiltArray.length == 3) {
						hc1 = lcBlfyService.getLinkXG(spiltArray[0]);
						hc2 = lcBlfyService.getLinkXG(spiltArray[1]);
						hc3 = lcBlfyService.getLinkXG(spiltArray[2]);
						linkbean.setLJXG(hc1 + ";" + hc2 + ";" + hc3);
					}
					if (spiltArray.length == 4) {
						hc1 = lcBlfyService.getLinkXG(spiltArray[0]);
						hc2 = lcBlfyService.getLinkXG(spiltArray[1]);
						hc3 = lcBlfyService.getLinkXG(spiltArray[2]);
						hc4 = lcBlfyService.getLinkXG(spiltArray[3]);
						linkbean.setLJXG(hc1 + ";" + hc2 + ";" + hc3 + ";" + hc4);
					}
				}
			}

			if (fiveLinks.get(i).getLJCN() != null && fiveLinks.get(i).getLJCN().length() < 3) {

				linkbean.setLJCN(lcBlfyService.getLinkCN(fiveLinks.get(i).getLJCN()));
			}
			if (fiveLinks.get(i).getLJCN() != null) {
				if (fiveLinks.get(i).getLJCN().length() > 3) {
					String spiltNum = fiveLinks.get(i).getLJCN();
					String[] spiltArray = spiltNum.split(";");
					String hc1 = null;
					String hc2 = null;
					String hc3 = null;
					String hc4 = null;
					if (spiltArray.length == 2) {
						hc1 = lcBlfyService.getLinkCN(spiltArray[0]);
						hc2 = lcBlfyService.getLinkCN(spiltArray[1]);
						linkbean.setLJCN(hc1 + ";" + hc2);
					}

					if (spiltArray.length == 3) {
						hc1 = lcBlfyService.getLinkCN(spiltArray[0]);
						hc2 = lcBlfyService.getLinkCN(spiltArray[1]);
						hc3 = lcBlfyService.getLinkCN(spiltArray[2]);
						linkbean.setLJCN(hc1 + ";" + hc2 + ";" + hc3);
					}
					if (spiltArray.length == 4) {
						hc1 = lcBlfyService.getLinkCN(spiltArray[0]);
						hc2 = lcBlfyService.getLinkCN(spiltArray[1]);
						hc3 = lcBlfyService.getLinkCN(spiltArray[2]);
						hc4 = lcBlfyService.getLinkCN(spiltArray[3]);
						linkbean.setLJCN(hc1 + ";" + hc2 + ";" + hc3 + ";" + hc4);
					}
				}
			}
			linkbean.setJYXM(fiveLinks.get(i).getXM());
			linkbean.setHSXM(fiveLinks.get(i).getPERSONNAME());
			linkbean.setLJTIME(fiveLinks.get(i).getLJTIME());
			linkbean.setJRCYXJ(fiveLinks.get(i).getJRCYXJ());
			linkbean.setPYCYXJ(fiveLinks.get(i).getPYCYXJ());
			result.add(linkbean);
		}
		System.out.println("成功返回：" + result);
		String callback = request.getParameter("callback");
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(result);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return result;
	}

	@RequestMapping("map/getGjzLcLink")
	public @ResponseBody List<GjzLc> getGjzLcLink(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		lcBlfyService.updateGjzLcLink(null);
		return null;
	}

	/**
	 * 查询配置
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getLc")
	public @ResponseBody Map<String, Object> getLc(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String nurseId = request.getParameter("nurseId");
		String gjzType = request.getParameter("gjzType");// 浆员类型：所有、忠诚、复苏........
		String address = request.getParameter("address");// 地址
		String sex = request.getParameter("sex");
		String manageNurse = request.getParameter("manageNurse");
		String age = request.getParameter("age");
		String pulpAge = request.getParameter("pulpAge");
		String currentTimePulp = request.getParameter("currentTimePulp");
		String lastTimePulps = request.getParameter("lastTimePulps");
		String lastYearPulps = request.getParameter("lastYearPulps");

		String times = request.getParameter("times");
		String communResult = request.getParameter("communResult");
		if (address != null) {
			address = new String(address.getBytes("ISO-8859-1"), "UTF-8");// "甘肃省定西市岷县闾井镇结山村";//URLDecoder.decode(request.getParameter("address"),
																			// "UTF-8");
		}
		int gt = -1;
		if (gjzType != null && !"".equals(gjzType)) {
			gt = Integer.parseInt(gjzType);
		}
		Map<String, Object> nurseGjzLc = lcBlfyService.getNurseGjzLc(nurseId, gt, address);
		List<GjzLc> obj = (List<GjzLc>) nurseGjzLc.get("jylc");
		// List<NurseGjzColligate> list=(List<NurseGjzColligate>)nurseGjzLc.get("ngc");

		GjzLc gLc = new GjzLc();
		StringBuilder sb = new StringBuilder();
		List<GjzLc> newGjzLc = lcBlfyService.getGjzLc(gLc);
		if (obj != null) {
			for (GjzLc gjzLc : obj) {
				sb.append("'" + gjzLc.getProviderNo() + "'" + ",");
			}
			if (sb.length() > 1) {
				gLc.setProviderNo(sb.toString().substring(0, sb.length() - 1));
				if (sex != null) {
					if (sex.equals("1")) {
						gLc.setSex("男");
						newGjzLc = lcBlfyService.getGjzLc(gLc);
					} else if (sex.equals("0")) {
						gLc.setSex("女");
						newGjzLc = lcBlfyService.getGjzLc(gLc);
					}
				}
				if (sex == null) {
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (manageNurse != null) {
					gLc.setLinkState(manageNurse);
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (manageNurse == null) {
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (age != null) {
					String[] ageArray = age.split(",");
					gLc.setAgeSmall(Integer.valueOf(ageArray[0]));
					gLc.setAgeBig(Integer.valueOf(ageArray[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (pulpAge != null) {
					String[] pulpAgeArray = pulpAge.split(",");
					gLc.setPulpAgeSmall(Integer.valueOf(pulpAgeArray[0]));
					gLc.setPulpAgeBig(Integer.valueOf(pulpAgeArray[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (currentTimePulp != null) {
					String[] newCurrentTimePulp = currentTimePulp.split(",");
					gLc.setCurrentTimePulpsSmall(Integer.valueOf(newCurrentTimePulp[0]));
					gLc.setCurrentTimePulpsBig(Integer.valueOf(newCurrentTimePulp[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (lastTimePulps != null) {
					String[] newlastTimePulps = lastTimePulps.split(",");
					gLc.setLastTimePulpsSmall(Integer.valueOf(newlastTimePulps[0]));
					gLc.setLastTimePulpsBig(Integer.valueOf(newlastTimePulps[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (lastYearPulps != null) {
					String[] newLastYear = lastYearPulps.split(",");
					gLc.setLastYearPulpsSmall(Integer.valueOf(newLastYear[0]));
					gLc.setLastYearPulpsBig(Integer.valueOf(newLastYear[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (times != null) {
					String[] newtime = times.split(",");
					gLc.setTimesSmall(Integer.valueOf(newtime[0]));
					gLc.setTimesBig(Integer.valueOf(newtime[1]));
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
				if (communResult != null) {
					gLc.setCommunResult(communResult);
					newGjzLc = lcBlfyService.getGjzLc(gLc);
				}
			}

		}
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("jylc", newGjzLc);
		map.put("ngc", nurseGjzLc.get("ngc"));
		map.put("ngcl", nurseGjzLc.get("ngcl"));
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;

	}

	/**
	 * 此接口用于重新构造经纬度信息表JZJYDZ 是完全构造的
	 */
	@RequestMapping("map/loadJzjydz")
	public void loadJzjydz() {
		List<String> adress = loadDataService.loadAddress();
		loadDataService.addJzjydz(adress);

		/**
		 * 
		 * 
		 * DataSourceContextHolder.setDataSourceType(DataSourceConst.mx);
		 * List<String>list=service.getAddressByGjzdzwed();
		 * System.out.println("list数组个数"+list.size()); System.out.println(list.get(0));
		 * loadDataService.addJzjydz(list);
		 */
	}

	/**
	 * 此接口用于重新构造经纬度信息表JZJYDZ 是不完全构造的
	 */
	@RequestMapping("map/loadJzjydzBygjzdzjwd")
	@ResponseBody
	public List<String> loadJzjydzBygjzdzjwd() {
		// 获取GJZ_DZ_JWD表里面身份证地址和NATIVEPLACE能对应上的
		// 即已经分配到最小单位村子的浆员，list存放的是这些浆员的卡号
		List<String> list = loadDataService.loadJzjydz();
		// 所有注册浆员的卡号集合
		List<String> noList = loadDataService.getAlladress();
		System.out.println("  ******************************" + list.size());
		// 从所有浆员里移除之后就剩下没有分配到村的浆员
		noList.removeAll(list);
		// 根据ID查询由GJZ_DZ_JWD查询出ADDRESS
		List<String> adress = jzjyloasService.getDzJwdByAddress(noList);
		loadDataService.addJzjydz(adress);
		return adress;
		// 保存到码表JZJYDZ没有村保存村，会逐级保存，最高到省
		/**
		 * 
		 * DataSourceContextHolder.setDataSourceType(DataSourceConst.mx);
		 * List<String>list=service.getAddressByGjzdzwed();
		 * System.out.println("list数组个数"+list.size()); System.out.println(list.get(0));
		 * loadDataService.addJzjydz(list);
		 */
	}

	/**
	 * 2018-5-22注释 用于重新生成GJZ_DZ_JWD表。 除非要再次重新生成表里数据
	 * 
	 */
	@RequestMapping("map/szGjzDzJwd")
	@ResponseBody
	public void szGjzDzJwd() {
		loadDataService.loadGjzDzJwdData(null);
	}

	@RequestMapping("map/updatelink")
	public @ResponseBody List<GjzLc> getGjzUpdateLink(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		lcBlfyService.updateLinkState(null);
		return null;
	}

	/**
	 * 查询建档成功未献浆、建档未成功浆员进行到那个步骤停止的
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getJyState")
	public @ResponseBody Map<String, Object> getJyState(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String startTime = request.getParameter("startTime");
		String cardId = request.getParameter("cardId");
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
		DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long dataDate = df.parse("2018-02-11").getTime();
		List<BodyCheckMX> mxState = null;
		List<BodyCheckJY> JyState = null;
		List<BodyCheckMX> resutl = new ArrayList<BodyCheckMX>();
		if (df.parse(startTime).getTime() > dataDate) {
			mxState = lcBlfyService.getMXJYState(cardId);
			for (BodyCheckMX bodyCheckMX : mxState) {
				bodyCheckMX.setCARDID(bodyCheckMX.getCARDID());
				if (bodyCheckMX.getCREATERQ() != null && "".equals(bodyCheckMX.getCREATERQ())) {
					bodyCheckMX.setCREATERQ(bodyCheckMX.getCREATERQ());
				}
				if (bodyCheckMX.getTJCJSJ() != null && "".equals(bodyCheckMX.getTJCJSJ())) {
					bodyCheckMX.setTJCJSJ(bodyCheckMX.getTJCJSJ());
				}
				if (bodyCheckMX.getTJJSSJ() != null && bodyCheckMX.getTJCJSJ() != null) {
					bodyCheckMX.setTJJSSJ(bodyCheckMX.getTJJSSJ());
					long kxsj = (df1.parse(bodyCheckMX.getTJJSSJ()).getTime()
							- df1.parse(bodyCheckMX.getTJCJSJ()).getTime()) / 1000 / 60;
					if (kxsj > 0) {
						bodyCheckMX.setTjSpace(kxsj);
					} else {
						bodyCheckMX.setTjSpace(1);
					}
				}
				if (bodyCheckMX.getJLJSSJ() != null && "".equals(bodyCheckMX.getJLJSSJ())) {
					bodyCheckMX.setJLSJ(bodyCheckMX.getJLJSSJ());
				}
				if (bodyCheckMX.getJLKSSJ() != null && bodyCheckMX.getJLJSSJ() != null) {
					bodyCheckMX.setJLKSSJ(bodyCheckMX.getJLKSSJ());
					long kxsj = (df1.parse(bodyCheckMX.getJLJSSJ()).getTime()
							- df1.parse(bodyCheckMX.getJLKSSJ()).getTime()) / 1000 / 60;
					if (kxsj > 0) {
						bodyCheckMX.setHjSpace(kxsj);
					} else {
						bodyCheckMX.setHjSpace(1);
					}

				}

				bodyCheckMX.setXM(bodyCheckMX.getXM());
				if (bodyCheckMX.getXTGG() != null && "".equals(bodyCheckMX.getXTGG())) {
					bodyCheckMX.setXTGG(bodyCheckMX.getXTGG());
				}
				if (bodyCheckMX.getLASTBODYCHECKDATE() != null && "".equals(bodyCheckMX.getLASTBODYCHECKDATE())) {
					bodyCheckMX.setLASTBODYCHECKDATE(bodyCheckMX.getLASTBODYCHECKDATE());
				}
				if (bodyCheckMX.getJSR() != null && !"".equals(bodyCheckMX.getJSR())) {
					bodyCheckMX.setJSR(lcBlfyService.getByIdJSR(bodyCheckMX.getJSR()));
				}

				resutl.add(bodyCheckMX);
			}
		} else {
			JyState = lcBlfyService.getJyState(cardId);
		}
		Map<String, Object> map = new HashMap<String, Object>();
		for (BodyCheckMX bodyCheckMX : resutl) {
			if ("1".equals(bodyCheckMX.getTJJG()) || bodyCheckMX.getTJJG() == null) {
				if ("1".equals(bodyCheckMX.getHJJG()) || bodyCheckMX.getHJJG() == null) {
					if ("1".equals(bodyCheckMX.getXTGG()) || bodyCheckMX.getXTGG() == null) {
						map.put("together", lcBlfyService.getByQualified(cardId));
					}
				}
			}
		}

		map.put("jy", JyState);
		map.put("mx", resutl);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	@RequestMapping("map/getgjzxx")
	public @ResponseBody Map<String, Object> getgjzxx(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		UpdateLC lc = new UpdateLC();
		lcBlfyService.getLCByGJZXX(null, startTime, endTime, lc);
		return null;
	}

	@RequestMapping("map/getzdjy")
	public @ResponseBody Map<String, Object> getzdjy(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		lcBlfyService.insertZDJYLX();
		return null;
	}

	@RequestMapping("map/getzdjylx")
	public @ResponseBody List<importantProvider> getzdjylx(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(lcBlfyService.getJYLXMB());

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return lcBlfyService.getJYLXMB();
	}

	@RequestMapping("map/gettest")
	public @ResponseBody Map<String, Object> gettest(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		loadDataService.loadGjzLcData();
		return null;
	}

	@RequestMapping("map/gePulpWeight")
	public @ResponseBody Map<String, Object> gePulpWeight(HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		Map<String, Object> map = MapUtils.thisLastPulp;
		if (map != null && map.size() > 0) {

		} else {
			map = villageColligateService.getPulpWeight(startTime, endTime);
			MapUtils.thisLastPulp = map;
		}
		// List<Object> list=villageColligateService.getPulpWeight(startTime, endTime);
		String callback = request.getParameter("callback");

		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	/**
	 * 用于修改数据库中表的浆量
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getjzjx")
	public @ResponseBody Map<String, Object> getjzjx(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Object> map = new HashMap<String, Object>();
		// List<JZAchievements> pulpWeight=jZAchievementsService.getPulp();
		jZAchievementsService.insertPulpWeight(null);
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	/**
	 * 统计全站绩效
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getqzjx")
	public @ResponseBody Map<String, Object> getqzjx(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Object> map = MapUtils.jzAchievements;
		if (map != null && map.size() > 0) {

		} else {
			List<JZAchievements> pulpWeight = jZAchievementsService.getPulpWeight();
			List<XYFZJX> xyfz = jZAchievementsService.getNewProviderPulp();
			List<LjJX> ljJXs = new ArrayList<LjJX>();
			List<YGJX> ygjx = jZAchievementsService.getLinkPulp();
			List<YLDX> yldx = jZAchievementsService.getYLDX();
			// 计算累计绩效
			for (JZAchievements jzAchievements : pulpWeight) {
				LjJX ljJX = new LjJX();
				for (XYFZJX xyfzjx : xyfz) {
					if (jzAchievements.getThisYearPulp1() != null && jzAchievements.getCJSJX1() != null
							&& jzAchievements.getXYGLJX1() != null && xyfzjx.getXYFZJX1() != null) {
						ljJX.setLJJX1(jzAchievements.getThisYearPulp1() - jzAchievements.getCJSJX1()
								- jzAchievements.getXYGLJX1() - xyfzjx.getXYFZJX1());
					}
					if (jzAchievements.getThisYearPulp2() != null && jzAchievements.getCJSJX2() != null
							&& jzAchievements.getXYGLJX2() != null && xyfzjx.getXYFZJX2() != null) {
						ljJX.setLJJX2(jzAchievements.getThisYearPulp2() - jzAchievements.getCJSJX2()
								- jzAchievements.getXYGLJX2() - xyfzjx.getXYFZJX2());
					}
					if (jzAchievements.getThisYearPulp3() != null && jzAchievements.getCJSJX3() != null
							&& jzAchievements.getXYGLJX3() != null && xyfzjx.getXYFZJX3() != null) {
						ljJX.setLJJX3(jzAchievements.getThisYearPulp3() - jzAchievements.getCJSJX3()
								- jzAchievements.getXYGLJX3() - xyfzjx.getXYFZJX3());
					}
					if (jzAchievements.getThisYearPulp4() != null && jzAchievements.getCJSJX4() != null
							&& jzAchievements.getXYGLJX4() != null && xyfzjx.getXYFZJX4() != null) {
						ljJX.setLJJX4(jzAchievements.getThisYearPulp4() - jzAchievements.getCJSJX4()
								- jzAchievements.getXYGLJX4() - xyfzjx.getXYFZJX4());
					}
					if (jzAchievements.getThisYearPulp5() != null && jzAchievements.getCJSJX5() != null
							&& jzAchievements.getXYGLJX5() != null && xyfzjx.getXYFZJX5() != null) {
						ljJX.setLJJX5(jzAchievements.getThisYearPulp5() - jzAchievements.getCJSJX5()
								- jzAchievements.getXYGLJX5() - xyfzjx.getXYFZJX5());
					}
					if (jzAchievements.getThisYearPulp6() != null && jzAchievements.getCJSJX6() != null
							&& jzAchievements.getXYGLJX6() != null && xyfzjx.getXYFZJX6() != null) {
						ljJX.setLJJX6(jzAchievements.getThisYearPulp6() - jzAchievements.getCJSJX6()
								- jzAchievements.getXYGLJX6() - xyfzjx.getXYFZJX6());
					}
					if (jzAchievements.getThisYearPulp7() != null && jzAchievements.getCJSJX7() != null
							&& jzAchievements.getXYGLJX7() != null && xyfzjx.getXYFZJX7() != null) {
						ljJX.setLJJX7(jzAchievements.getThisYearPulp7() - jzAchievements.getCJSJX7()
								- jzAchievements.getXYGLJX7() - xyfzjx.getXYFZJX7());
					}
					if (jzAchievements.getThisYearPulp8() != null && jzAchievements.getCJSJX8() != null
							&& jzAchievements.getXYGLJX8() != null && xyfzjx.getXYFZJX8() != null) {
						ljJX.setLJJX8(jzAchievements.getThisYearPulp8() - jzAchievements.getCJSJX8()
								- jzAchievements.getXYGLJX8() - xyfzjx.getXYFZJX8());
					}
					if (jzAchievements.getThisYearPulp9() != null && jzAchievements.getCJSJX9() != null
							&& jzAchievements.getXYGLJX9() != null && xyfzjx.getXYFZJX9() != null) {
						ljJX.setLJJX9(jzAchievements.getThisYearPulp9() - jzAchievements.getCJSJX9()
								- jzAchievements.getXYGLJX9() - xyfzjx.getXYFZJX9());
					}
					if (jzAchievements.getThisYearPulp10() != null && jzAchievements.getCJSJX10() != null
							&& jzAchievements.getXYGLJX10() != null && xyfzjx.getXYFZJX10() != null) {
						ljJX.setLJJX10(jzAchievements.getThisYearPulp10() - jzAchievements.getCJSJX10()
								- jzAchievements.getXYGLJX10() - xyfzjx.getXYFZJX10());
					}
					if (jzAchievements.getThisYearPulp11() != null && jzAchievements.getCJSJX11() != null
							&& jzAchievements.getXYGLJX11() != null && xyfzjx.getXYFZJX11() != null) {
						ljJX.setLJJX11(jzAchievements.getThisYearPulp11() - jzAchievements.getCJSJX11()
								- jzAchievements.getXYGLJX11() - xyfzjx.getXYFZJX11());
					}
					if (jzAchievements.getThisYearPulp12() != null && jzAchievements.getCJSJX12() != null
							&& jzAchievements.getXYGLJX12() != null && xyfzjx.getXYFZJX12() != null) {
						ljJX.setLJJX12(jzAchievements.getThisYearPulp12() - jzAchievements.getCJSJX12()
								- jzAchievements.getXYGLJX12() - xyfzjx.getXYFZJX12());
					}

				}
				ljJXs.add(ljJX);

			}
			map.put("jl", pulpWeight);
			map.put("xyfz", xyfz);
			map.put("ljJXs", ljJXs);
			map.put("ygjx", ygjx);
			map.put("yldx", yldx);
			map.put("pulpWeight", jZAchievementsService.selectPulp());
		}
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	/**
	 * 浆员类型统计信息
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/mapDate")
	@ResponseBody
	public Map<String, Integer> testHSTJ(HttpServletResponse response, HttpServletRequest request) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		List<VillageColligate> tList = MapUtils.villList;
		Map<String, Integer> map = new HashMap<String, Integer>();
		if (tList.size() > 0) {

		} else {
			tList = lcBlfyService.getVillStatistics();
			MapUtils.villList = tList;
		}
		for (VillageColligate vill : tList) {
			map.put("allProviderNum", vill.getAllProviderNum());// 所有浆员
			map.put("currentTimePNum", vill.getCurrentTimePNum());// 今年已进站
			map.put("currentTimeAddPNum", vill.getCurrentTimeAddPNum());// 今年新增
			map.put("currentTimeFuSuPNum", vill.getCurrentTimeFuSuPNum());// 复苏浆员
			map.put("currentTimeZCPNum", vill.getCurrentTimeZCPNum());// z忠诚浆员
			map.put("comedNotConnPNum", vill.getComedNotConnPNum());// 未连接浆员
			map.put("currentTimeNotComedPNum", vill.getCurrentTimeNotComedPNum());// 当期未进站浆员
			map.put("xiuMianPNum", vill.getXiuMianPNum());// 休眠浆员
			map.put("liuShiPNum", vill.getLiuShiPNum());// 流失浆员
			map.put("connXMPNum", vill.getConnXMPNum());// 已链接休眠浆员
			map.put("notConnXMPNum", vill.getNotConnXMPNum());// 未链接休眠浆员
		}
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return map;
	};

	/**
	 * 按月统计血浆的袋数
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/pulpQuantityDetailMonth")
	@ResponseBody
	public Map<String, Integer> pulpQuantityDetailMonth(HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Integer> plasma = plasmaStatisticsService.pulpQuantityDetailMonth();
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(plasma);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}

		return plasma;
	};

	@RequestMapping("map/pulpQuantityDetailRound")
	@ResponseBody
	public Map<String, PlasmaResult> getRoundsOfStatistical(HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, PlasmaResult> map = plasmaStatisticsService.getRoundsOfStatistical2();
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	/**
	 * 根据村落名称查询浆员类型的总人数
	 * 
	 * @param response
	 * @param request
	 * @return
	 * 
	 * @throws Exception
	 */
	@RequestMapping("map/getJyTypeNum")
	@ResponseBody
	public List<ProviderType> getJyTypeNum(HttpServletRequest request, HttpServletResponse response) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String villageName = new String(request.getParameter("villageName").getBytes("ISO-8859-1"), "UTF-8");
		String callback = request.getParameter("callback");
		List<ProviderType> list = gjzDzJwdService.getProviderTypes(villageName);
		System.out.println(list);
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(list);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return list;
	}

	/**
	 * 统计在册人数
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getOutProvider")
	@ResponseBody
	public Map<String, Object> getOutProvider(HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		Map<String, Object> map = MapUtils.thisLast;
		if (map != null && map.size() > 0) {

		} else {
			Map<String, Object> map1 = villageColligateService.getByOutProvider();
			/*
			 * for (PulpWeight pulpWeight : people) { ThisLastDiff tDiff = new
			 * ThisLastDiff(); tDiff.setThisLastDiff1(
			 * Integer.valueOf(pulpWeight.getThisYear1()) -
			 * Integer.valueOf(pulpWeight.getLastYesr1())); tDiff.setThisLastDiff2(
			 * Integer.valueOf(pulpWeight.getThisYear2()) -
			 * Integer.valueOf(pulpWeight.getLastYesr2())); tDiff.setThisLastDiff3(
			 * Integer.valueOf(pulpWeight.getThisYear3()) -
			 * Integer.valueOf(pulpWeight.getLastYesr3())); tDiff.setThisLastDiff4(
			 * Integer.valueOf(pulpWeight.getThisYear4()) -
			 * Integer.valueOf(pulpWeight.getLastYesr4())); tDiff.setThisLastDiff5(
			 * Integer.valueOf(pulpWeight.getThisYear5()) -
			 * Integer.valueOf(pulpWeight.getLastYesr5())); tDiff.setThisLastDiff6(
			 * Integer.valueOf(pulpWeight.getThisYear6()) -
			 * Integer.valueOf(pulpWeight.getLastYesr6())); tDiff.setThisLastDiff7(
			 * Integer.valueOf(pulpWeight.getThisYear7()) -
			 * Integer.valueOf(pulpWeight.getLastYesr7())); tDiff.setThisLastDiff8(
			 * Integer.valueOf(pulpWeight.getThisYear8()) -
			 * Integer.valueOf(pulpWeight.getLastYesr8())); tDiff.setThisLastDiff9(
			 * Integer.valueOf(pulpWeight.getThisYear9()) -
			 * Integer.valueOf(pulpWeight.getLastYesr9())); tDiff.setThisLastDiff10(
			 * Integer.valueOf(pulpWeight.getThisYear10()) -
			 * Integer.valueOf(pulpWeight.getLastYesr10())); tDiff.setThisLastDiff11(
			 * Integer.valueOf(pulpWeight.getThisYear11()) -
			 * Integer.valueOf(pulpWeight.getLastYesr11())); tDiff.setThisLastDiff12(
			 * Integer.valueOf(pulpWeight.getThisYear12()) -
			 * Integer.valueOf(pulpWeight.getLastYesr12())); peoDiff.add(tDiff); }
			 */
			map.put("peole", villageColligateService.getNewPeople(startTime, endTime));
			map.put("zcrs", map1);
			MapUtils.thisLast = map;
		}
		String callback = request.getParameter("callback");
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	/**
	 * 统计联络人
	 * 
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getJSRList")
	@ResponseBody
	public Map<String, Object> getJSRList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String startTime = new String(request.getParameter("startTime"));
		String endTime = new String(request.getParameter("endTime"));
		Map<String, Object> map = villageColligateService.getByJSRProvider(startTime, endTime);
		String callback = request.getParameter("callback");
		if (callback != null && !"".equals(callback)) {

			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);

			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return null;
		}
		return map;
	}

	@RequestMapping("map/collectPlasmaFrequency")
	@ResponseBody
	public Map<String, Map<String, String>> getCollectPlasmaFrequency(HttpServletResponse response,
			HttpServletRequest request) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Map<String, String>> maps = plasmaStatisticsService.getCollectPlasmaFrequency();
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(maps);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return maps;
	}

	//
	@RequestMapping("map/plasmaSourceMember")
	@ResponseBody
	public Map<String, Results> getPlasmaSourceMember(HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Results> maps = plasmaStatisticsService.getPlasmaSourceMember();
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(maps);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return maps;
	}

	/**
	 * 根据时间、类型、介绍人姓名查浆员来浆站的方式
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getRecruitmentMethod")
	@ResponseBody
	public List<RecruitmentMethod> getRecruitmentMethod(HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String workGroup = request.getParameter("workGroup");
		String jsr = request.getParameter("jsr");
		int type = 0;
		List<RecruitmentMethod> list = null;
		if (workGroup != null) {
			type = Integer.valueOf(workGroup);
			list = recruitmentMethodService.getNewPulpsDZ(startTime, endTime, type, null);
		}
		if (jsr != null) {
			list = recruitmentMethodService.getNewPulpsDZ(startTime, endTime, null, jsr);
		}

		ObjectMapper mapper = new ObjectMapper();
		String json = null;
		try {
			json = mapper.writeValueAsString(list);
		} catch (JsonProcessingException e1) {
			e1.printStackTrace();
		}

		String retStr = callback + "(" + json + ")";
		try {
			PrintWriter out = response.getWriter();
			out.print(retStr);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 根据时间、类型查浆员来浆站的方式
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getRecruitmentMethodType")
	public String getRecruitmentMethodType(HttpServletRequest request, HttpServletResponse response) {
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		Map<String, Object> map = recruitmentMethodService.getNewPulpsAddress(startTime, endTime);

		ObjectMapper mapper = new ObjectMapper();
		String json = null;
		try {
			json = mapper.writeValueAsString(map);
		} catch (JsonProcessingException e1) {
			e1.printStackTrace();
		}

		String retStr = callback + "(" + json + ")";
		try {
			PrintWriter out = response.getWriter();
			out.print(retStr);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * 根据时间、介绍人查浆员来浆站的方式
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getRecruitmentMethodJSR")
	public String getRecruitmentMethodJSR(HttpServletRequest request, HttpServletResponse response) {
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		Map<String, Object> map = recruitmentMethodService.getNewPulpsJsr(startTime, endTime);

		ObjectMapper mapper = new ObjectMapper();
		String json = null;
		try {
			json = mapper.writeValueAsString(map);
		} catch (JsonProcessingException e1) {
			e1.printStackTrace();
		}

		String retStr = callback + "(" + json + ")";
		try {
			PrintWriter out = response.getWriter();
			out.print(retStr);
			out.flush();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}

	@RequestMapping("map/plasmaCountByPieChart")
	@ResponseBody
	public Map<String, Map<String, Integer>> getPlasmaCountByPieChart(HttpServletResponse response,
			HttpServletRequest request, String date) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		String callback = request.getParameter("callback");
		Map<String, Map<String, Integer>> maps = plasmaStatisticsService.getPlasmaCountByPieChart(date);
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(maps);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return maps;
	}

	/**
	 * 浆站个性化频次统计表
	 * 
	 * @param response
	 * @param request
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("map/getPulpFrequency")
	@ResponseBody
	public Map<String, Object> getPulpFrequency(HttpServletResponse response, HttpServletRequest request)
			throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		Map<String, Object> map = recruitmentMethodService.getPulpFrequency();

		String callback = request.getParameter("callback");
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return map;
	}
	 /**
     * 统计浆员频次、反站人数的方法
     */
	@RequestMapping("map/frequencyCount")
	@ResponseBody
	public List<Map<String, Map<String, FrequencyResult>>> getPlasmaComprehensiveStatisticsResult(
			HttpServletResponse response, HttpServletRequest request) throws Exception {
		response.setHeader("Access-Control-Allow-Origin", "*");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html");
		response.setCharacterEncoding("utf-8");
		List<Map<String, Map<String, FrequencyResult>>> map = plasmaStatisticsService
				.getPlasmaComprehensiveStatisticsResult();
		String callback = request.getParameter("callback");
		if (callback != null && !"".equals(callback)) {
			ObjectMapper mapper = new ObjectMapper();
			String json = mapper.writeValueAsString(map);
			String retStr = callback + "(" + json + ")";
			try {
				PrintWriter out = response.getWriter();
				out.print(retStr);
				out.flush();
				out.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return map;
	}
}
